﻿<html><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=utf-8" /><META NAME="save" CONTENT="history" /><title xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt">Ribbon Controls Sample</title><META NAME="Description" CONTENT="This sample runs only in Microsoft Office Excel 2007."></META><META NAME="MS.LOCALE" CONTENT="en-us" /><style>
body
{font-family:Verdana;font-size:medium;}
div#mainSection, div#header
{font-size:70%;width: 100%;}
div#mainBody
{font-size:90%;}
div#mainSection div table
{font-size: 100%;text-align: left;}
span#nsrTitle
{color:#003399;font-size:90%;font-weight:600;}
div#header
{background-color:#D4DFFF;}
.heading
{font-size:120%;color:#003399;}
.subHeading
{font-size:100%;margin-bottom:4;}
li
{margin-top:-2;margin-bottom:3;}
p
{margin-top:10;margin-bottom:5;}
div.tableSection p
{margin-top:1;margin-bottom:4;}	
div#mainSection table th
{background-color:#EFEFF7;color:#000066;text-align:left;}
div#mainSection table td
{background-color:#F7F7FF;}
div#mainSection table
{margin-top:5px;margin-bottom: px;}
.style1{color: Green;}
			</style></head><body><div id="header"><table width="100%" id="topTable"></table></div><div id="mainSection"><div id="mainBody"><p><span class="style1">&#39; Copyright © Microsoft Corporation. All Rights Reserved.
    </span>
    <br class="style1" />
    <span class="style1">&#39; This code released under the terms of the </span>
    <br class="style1" />
    <span class="style1">&#39; Microsoft Public License (MS-PL,
    <a href="http://opensource.org/licenses/ms-pl.html">
    http://opensource.org/licenses/ms-pl.html</a>.)</span></p><br /><div class="introduction"><div class="alert"><table width="100%" cellspacing="0" cellpadding="0" xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt"><tr><th align="left"><b>Note:</b></th></tr><tr><td><p>This sample runs in Microsoft Office Excel 2007 and higher.</p></td></tr></table></div><p xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt">This sample demonstrates how to create a custom tab that appears on the Ribbon of a Microsoft Office Excel worksheet. This custom Ribbon demonstrates most of the controls available in the <span class="ui">Office Ribbon Controls</span> group of the Visual Studio <span class="ui">Toolbox</span>. For more information about using these controls, see Ribbon Designer.</p><div class="alert"><table width="100%" cellspacing="0" cellpadding="0" xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt"><tr><th align="left"><b>Security Note:</b></th></tr><tr><td><p>This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties.</p></td></tr></table></div><p xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt">For information about how to install the sample project on your computer, see How to: Install and Use Sample Files Found in Help.</p></div><h3 class="procedureSubHeading" xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt">To run this sample</h3><div class="subSection"><ol xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt"><li><p>Press F5.</p></li><li><p>An Excel worksheet appears. The Ribbon of the worksheet displays a custom tab named <span class="ui">Ribbon Control Sample</span>. </p><p>The Ribbon does not display any other tabs, because the StartFromScratch property of the custom Ribbon is set to <span class="keyword">true</span>. </p></li></ol></div><h1 class="heading" xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt"><span onclick="ExpandCollapse(requirementsTitleToggle)" style="cursor:default;" onkeypress="ExpandCollapse_CheckKey(requirementsTitleToggle, event)" tabindex="0">Requirements</span></h1><div id="requirementsTitleSection" class="section"><p xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt">This sample requires the following applications:</p><ul xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt"><li><p>
            Visual Studio Tools for Office.</p></li><li><p>Microsoft Office Excel 2007.</p></li></ul></div><h1 class="heading" xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt"><span onclick="ExpandCollapse(demonstratesToggle)" style="cursor:default;" onkeypress="ExpandCollapse_CheckKey(demonstratesToggle, event)" tabindex="0">Demonstrates</span></h1><div id="demonstratesSection" class="section"><p xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt">This sample demonstrates the following concepts:</p><ul xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt"><li><p>Customizing a tab by using a <span class="ui">Ribbon (Visual Designer)</span> item template.</p></li><li><p>Hiding all built-in tabs and most commands on the Office menu, and displaying the customizations defined in this Ribbon item only. </p></li><li><p>Adding custom groups and controls to the Ribbon designer.</p></li><li><p>Handling the events of controls on the Ribbon.</p></li><li><p>Changing the properties of controls at run time.</p></li><li><p>Dynamically adding controls to a menu at run time.</p></li><li><p>Dynamically adding items to a gallery at run time.</p></li><li><p>Showing and hiding actions pane controls by using buttons on the Ribbon.</p></li></ul><h1 class="heading" xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt"><span onclick="ExpandCollapse(sectionToggle0)" style="cursor:default;" onkeypress="ExpandCollapse_CheckKey(sectionToggle0, event)" tabindex="0">Working with Sheets Group</span></h1><div id="sectionSection0" class="section"><p xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt">The following table describes the controls that appear in the <span class="ui">Working with Sheets</span> group of the custom Ribbon.</p><div class="caption"></div><div class="tableSection"><table width="50%" cellspacing="2" cellpadding="5" frame="lhs" xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt"><tr><th><p>Control</p></th><th><p>Description</p></th><th><p>Action / Result</p></th></tr><tr><td><p><span class="ui">Show Actions Pane</span></p></td><td><p>A toggle button that appears pressed or not pressed.</p></td><td><p>Click <span class="ui">Show Actions Pane</span>. </p><p>An actions pane appears beside the worksheet. </p><p>Click <span class="ui">Show Actions Pane</span> a second time to hide the actions pane.</p></td></tr><tr><td><p>Face buttons</p></td><td><p>Three buttons contained in a button group. These buttons are added to the button group because they are related to one another. Buttons in a button group have a shiny appearance.</p></td><td><p>Click a face button.</p><p>Cell A1 displays a matching image.</p></td></tr><tr><td><p><span class="ui">Alignment</span></p></td><td><p>A split button. A split button is a button with a menu attached. The <span class="ui">Alignment</span> split button menu contains three buttons. The OfficeImageId property of the <span class="ui">Alignment</span> split button is set to the ID of a built-in Office alignment control.</p></td><td><p>Click <span class="ui">Right Align</span>, <span class="ui">Left Align</span>, or <span class="ui">Center Align</span> in the <span class="ui">Alignment</span> split button menu.</p><p>The text that appears in cell A3 is right justified, left justified, or centered.</p></td></tr><tr><td><p><span class="ui">Color</span></p></td><td><p>A gallery that presents an array of colored spheres from which you can select. </p></td><td><p>Click <span class="ui">Color</span>, and then select a color from the gallery.</p><p>A sphere that has the selected color appears in cell A6.</p></td></tr><tr><td><p><span class="ui">FormatChart</span></p></td><td><p>A drop-down control that contains a list of chart formats. Unlike a combo box, you cannot type a selection in a drop-down control. </p></td><td><p>Click <span class="ui">Format Chart</span>, and then select a format from the list.</p><p>The format of the chart that appears on the worksheet changes to match the format that you selected.</p></td></tr><tr><td><p><span class="ui">MRU Find</span></p></td><td><p>A combo box. You can either type or select a choice.</p></td><td><p>Click the <span class="ui">MRU Find</span> combo box, and then select text from the list.</p><p>- or -</p><p>In the <span class="ui">MRU Find</span> combo box, type any text and then press ENTER.</p><p>A message box appears that identifies the location of the text in the worksheet.</p></td></tr></table></div></div><h1 class="heading" xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt"><span onclick="ExpandCollapse(sectionToggle1)" style="cursor:default;" onkeypress="ExpandCollapse_CheckKey(sectionToggle1, event)" tabindex="0">Building Dynamic Menu Group</span></h1><div id="sectionSection1" class="section"><p xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt">The following table describes the controls that appear in the <span class="ui">Building a Dynamic Menu</span> group of the custom Ribbon.</p><div class="caption"></div><div class="tableSection"><table width="50%" cellspacing="2" cellpadding="5" frame="lhs" xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt"><tr><th><p>Control</p></th><th><p>Description</p></th><th><p>Action / Result</p></th></tr><tr><td><p><span class="ui">Dynamic Menu</span></p></td><td><p>A menu. A menu is a drop-down list that can contain other Ribbon controls.</p><p>The Dynamic property of this menu is set to <span class="keyword">true</span>. This enables the menu to be dynamically updated at run time.</p></td><td><p>Click <span class="ui">Dynamic Menu</span> to display a menu of controls.</p></td></tr><tr><td><p><span class="ui">CheckBox</span>, <span class="ui">DropDown</span>, <span class="ui">SubMenu</span>, <span class="ui">Gallery</span>, <span class="ui">Button</span>, <span class="ui">Separator</span></p></td><td><p>A set of check boxes. You can select or clear a check box to turn on or off an option.</p><p>Each check box represents a Ribbon control that you can add to <span class="ui">Dynamic Menu</span>.</p></td><td><p>Click a checkbox to add a Ribbon control to <span class="ui">Dynamic Menu</span>.</p></td></tr></table></div></div></div></div>
    </div>
</body></html>